package com.ikun.starters.jwt.auto;

import com.ikun.starters.jwt.impl.TokenService;
import com.ikun.starters.jwt.properties.TokenConfigurationProperties;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author ximeng
 * @title: TokenAutoConfiguration
 */
@SpringBootConfiguration
@ConditionalOnClass(TokenService.class)
@EnableConfigurationProperties(TokenConfigurationProperties.class)  //引入可变的参数
public class TokenAutoConfiguration {

    @Bean
    public TokenService tokenService(TokenConfigurationProperties tokenConfigurationProperties){
     return new TokenService(tokenConfigurationProperties.getExpireTime(),tokenConfigurationProperties.getTokenSignKey(),tokenConfigurationProperties.getTokenKey());
    }

}
